local explosions = {}

function MakePlasmaBallExplosion (name, size)
  local ex = {}
  
  for i = 1, 25 do
    local frameName = name .. "_FRAME" .. i
    
    ex["frame" .. i] = { 
      class = "CExpGenSpawner",
      properties = {
        pos = [[0, 0, 0]],  
        delay = i,				  
        explosionGenerator = "custom:" .. frameName,
      },
      air = 1,
      water = 1,
      ground = 1,
      count = 1,
    }
    
    local number = (i <= 9) and ("0" .. i) or i
    local alpha  = math.min(1, (26 - i) * 0.2)
    -- .9 .7 .5 .4 .3
    
    explosions[frameName] = {	
      plasmaball = {
        class = "CSimpleParticleSystem",
        ["properties"] = {
          sizeGrowth = 0,
          sizeMod = 1.0,
          pos = [[0, 0, 0]],
          emitVector = [[0, 1, 0]],
          gravity = [[0, 0, 0]],
          colorMap = [[0 0 0 0.01  1 1 1 ]] .. alpha .. [[  0 0 0 0.01]],
          texture = "plasmaball" .. number,
          airdrag = 1,
          particleLife = 2,  --1 doesn't show
          particleLifeSpread = 0,
          numParticles = 1,
          particleSpeed = 0,
          particleSpeedSpread = 0,
          particleSize = size,
          particleSizeSpread = 0,
          emitRot = 0,
          emitRotSpread = 1,
          directional = 0,
          alwaysVisible = 1,
        },
        air = 1,
        water = 1,
        ground = 1,
        count = 1,
      },
    } 
  end
  
  explosions[name .. "_ANIMATION"] = ex
  
  explosions[name] = {	
    useDefaultExplosions = 1,
    
    plasmaball = { 
      class = "CExpGenSpawner",
      properties = {
        pos = [[0, ]] .. (5 + size * 0.5) .. [[, 0]],  --7, 13, 18, 18  
        delay = 0,				  
        explosionGenerator = "custom:" .. name .. "_ANIMATION",
      },
      air = 1,
      water = 1,
      ground = 1,
      count = 1,
    },
    
    groundflash = {
      flashSize = size * 2.0,  --55, 100, 130, 200
      flashAlpha = 1.8,
      circleGrowth = size * 0.2,  --4, 6, 6, 10
      circleAlpha = 0.5,
      color = [[1, 0.7, 0.4]],
      ttl = 9 + size * 0.2,  --15, 15, 18, 22
    },
  }  
end

MakePlasmaBallExplosion("PLASMABALL10", 10)
MakePlasmaBallExplosion("PLASMABALL15", 15)
MakePlasmaBallExplosion("PLASMABALL25", 25)
MakePlasmaBallExplosion("PLASMABALL35", 35)
MakePlasmaBallExplosion("PLASMABALL45", 45)
MakePlasmaBallExplosion("PLASMABALL55", 55)
MakePlasmaBallExplosion("PLASMABALL65", 65)  --?

return explosions